/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.DAO;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import vn.ac.c0910g.assignment.Entity.PaymentDetails;
import vn.ac.c0910g.assignment.Entity.PaymentDetailsFacade;

/**
 *
 * @author BachLe
 */
public class PaymentDetailsDAO {
    PaymentDetailsFacade paymentDetailsFacade = lookupPaymentDetailsFacadeBean();

    public PaymentDetailsDAO(){

    }
    private PaymentDetailsFacade lookupPaymentDetailsFacadeBean() {
        try {
            Context c = new InitialContext();
            return (PaymentDetailsFacade) c.lookup("java:global/Alluring_Decors/Alluring_Decors-ejb/PaymentDetailsFacade!vn.ac.c0910g.assignment.Entity.PaymentDetailsFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<PaymentDetails> getAllPaymentDetails(){
        return this.paymentDetailsFacade.findAll();
    }

    public void addPaymentDetails(PaymentDetails pd){
        paymentDetailsFacade.create(pd);
    }

    public void updatePaymentDetails(PaymentDetails pd){
        paymentDetailsFacade.edit(pd);
    }

    public void deletePaymentDetails(PaymentDetails pd){
        paymentDetailsFacade.remove(pd);
    }

    public PaymentDetails findPaymentDetailsById(String Id){
        return paymentDetailsFacade.find(Id);
    }
}
